using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public delegate void CallbackConditionItem(ConditionItem item);
public class ConditionItem : MonoBehaviour
{
    public enum BackgroundState
    {
        Unselect,
        Selected
    }
    public Text m_Text;
    public Image m_Background;
    public Color m_SelectedColor;
    public Color m_UnselectColor;
    public CallbackConditionItem m_OnClicked;

    public ShipEvent m_ShipEvent;
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void Init(ShipEvent shipEvent)
    {
        m_ShipEvent = shipEvent;
        m_Text.text = m_ShipEvent.m_Name;
    }

    public void OnClicked()
    {
        if (m_OnClicked != null)
            m_OnClicked(this);
    }

    public void SetBackgroundState(BackgroundState state)
    {
        switch(state)
        {
            case BackgroundState.Unselect:
                m_Background.color = m_UnselectColor;
                break;
            case BackgroundState.Selected:
                m_Background.color = m_SelectedColor;
                break;
        }
    }

    public void SetName(string name)
    {
        m_ShipEvent.m_Name = name;
        m_Text.text = name;
    }
}
